# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: halt matmult sort testfiles testcase yield combined Problem2 exec exec2 dcv dcv2 wrinkle proj3test proj4test multipleProj1 forkMatmult forkSort\
	Cashreg Clerk Manager Customer StockBoy

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

multipleProj1.o: multipleProj1.c
	$(CC) $(CFLAGS) -c multipleProj1.c
multipleProj1: multipleProj1.o start.o
	$(LD) $(LDFLAGS) start.o multipleProj1.o -o multipleProj1.coff
	../bin/coff2noff multipleProj1.coff multipleProj1

forkMatmult.o: forkMatmult.c
	$(CC) $(CFLAGS) -c forkMatmult.c
forkMatmult: forkMatmult.o start.o
	$(LD) $(LDFLAGS) start.o forkMatmult.o -o forkMatmult.coff
	../bin/coff2noff forkMatmult.coff forkMatmult

forkSort.o: forkSort.c
	$(CC) $(CFLAGS) -c forkSort.c
forkSort: forkSort.o start.o
	$(LD) $(LDFLAGS) start.o forkSort.o -o forkSort.coff
	../bin/coff2noff forkSort.coff forkSort

testcase.o: testcase.c
	$(CC) $(CFLAGS) -c testcase.c
testcase: testcase.o start.o
	$(LD) $(LDFLAGS) start.o testcase.o -o testcase.coff
	../bin/coff2noff testcase.coff testcase

yield.o: yield.c
	$(CC) $(CFLAGS) -c yield.c
yield: yield.o start.o
	$(LD) $(LDFLAGS) start.o yield.o -o yield.coff
	../bin/coff2noff yield.coff yield

combined.o: combined.c
	$(CC) $(CFLAGS) -c combined.c
combined: combined.o start.o
	$(LD) $(LDFLAGS) start.o combined.o -o combined.coff
	../bin/coff2noff combined.coff combined
	
exec.o: exec.c
	$(CC) $(CFLAGS) -c exec.c
exec: exec.o start.o
	$(LD) $(LDFLAGS) start.o exec.o -o exec.coff
	../bin/coff2noff exec.coff exec
	
exec2.o: exec2.c
	$(CC) $(CFLAGS) -c exec2.c
exec2: exec2.o start.o
	$(LD) $(LDFLAGS) start.o exec2.o -o exec2.coff
	../bin/coff2noff exec2.coff exec2

dcv.o: dcv.c
	$(CC) $(CFLAGS) -c dcv.c
dcv: dcv.o start.o
	$(LD) $(LDFLAGS) start.o dcv.o -o dcv.coff
	../bin/coff2noff dcv.coff dcv
	
dcv2.o: dcv2.c
	$(CC) $(CFLAGS) -c dcv2.c
dcv2: dcv2.o start.o
	$(LD) $(LDFLAGS) start.o dcv2.o -o dcv2.coff
	../bin/coff2noff dcv2.coff dcv2

wrinkle.o: wrinkle.c
	$(CC) $(CFLAGS) -c wrinkle.c
wrinkle: wrinkle.o start.o
	$(LD) $(LDFLAGS) start.o wrinkle.o -o wrinkle.coff
	../bin/coff2noff wrinkle.coff wrinkle
	

proj3test.o: proj3test.c
	$(CC) $(CFLAGS) -c proj3test.c
proj3test: proj3test.o start.o
	$(LD) $(LDFLAGS) start.o proj3test.o -o proj3test.coff
	../bin/coff2noff proj3test.coff proj3test
	
proj4test.o: proj4test.c
	$(CC) $(CFLAGS) -c proj4test.c
proj4test: proj4test.o start.o
	$(LD) $(LDFLAGS) start.o proj4test.o -o proj4test.coff
	../bin/coff2noff proj4test.coff proj4test
	
Problem2.o: Problem2.c
	$(CC) $(CFLAGS) -c Problem2.c
Problem2: Problem2.o start.o
	$(LD) $(LDFLAGS) start.o Problem2.o -o Problem2.coff
	../bin/coff2noff Problem2.coff Problem2

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult

testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles
	
Customer.o: Customer.c
	$(CC) $(CFLAGS) -c Customer.c
Customer: Customer.o start.o
	$(LD) $(LDFLAGS) start.o Customer.o -o Customer.coff
	../bin/coff2noff Customer.coff Customer

Cashreg.o: Cashreg.c
	$(CC) $(CFLAGS) -c Cashreg.c
Cashreg: Cashreg.o start.o
	$(LD) $(LDFLAGS) start.o Cashreg.o -o Cashreg.coff
	../bin/coff2noff Cashreg.coff Cashreg

Manager.o: Manager.c
	$(CC) $(CFLAGS) -c Manager.c
Manager: Manager.o start.o
	$(LD) $(LDFLAGS) start.o Manager.o -o Manager.coff
	../bin/coff2noff Manager.coff Manager

StockBoy.o: StockBoy.c
	$(CC) $(CFLAGS) -c StockBoy.c
StockBoy: StockBoy.o start.o
	$(LD) $(LDFLAGS) start.o StockBoy.o -o StockBoy.coff
	../bin/coff2noff StockBoy.coff StockBoy

Clerk.o: Clerk.c
	$(CC) $(CFLAGS) -c Clerk.c
Clerk: Clerk.o start.o
	$(LD) $(LDFLAGS) start.o Clerk.o -o Clerk.coff
	../bin/coff2noff Clerk.coff Clerk


clean:
	rm -f *.o *.coff
